﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Data;

namespace PJ.Business
{
    /// <summary>
    /// Link class
    /// </summary>
    /// <typeparam name="OD">Inner data object</typeparam>
    public abstract class Link<OD> : BusinessObject<OD>, ILink
        where OD : ILinkData
    {
        public Link(OD data)
            : base(data)
        {
        }
        public Link()
        {
        }
        public string LeftID
        {
            get
            {

                return ObjectData.LeftId;
            }
            set
            {
                if (ObjectData.LeftId != value)
                {
                    ObjectData.LeftId = value;
                }
            }
        }
        public string RightID
        {
            get
            {
                return ObjectData.RightId;
            }
            set
            {
                if (ObjectData.RightId != value)
                {
                    ObjectData.RightId = value;
                }
            }
        }


        public override void CopyFrom(IBusinessObject data)
        {
            base.CopyFrom(data);
            ILink idata = data as ILink;
            if (idata != null)
            {
                this.RightID = idata.RightID;
                this.LeftID = idata.LeftID;
            }
        }
    }

}

